今天要解決什麼?
- 把常見信貸觀念(收入、負債比、繳款紀錄、信用卡動用率…)變成簡單規則
- 計算分數(Base 600 分起),輸出 分數、等級 與 扣分原因
- 這套結構未來可以慢慢調整權重、加新變數,逐步進階成你自己的風險打分卡
會用到的指標
- income_twd:月收入(TWD)
- dti:負債比(Debt-to-Income,月負債/月收入)
- late_12m:過去 12 個月遲繳次數
- util:信用卡動用率(已用額度 / 總額度)
- age:年齡
- history_years:信用歷史長度(年)
- inq_6m:近 6 個月查詢次數(申貸/辦卡)
- buffer_months:現金儲備可支撐幾個月生活
Python 小實作
# 規則說明:
# - 基礎分 600 分,依各項指標加減分,最後裁剪於 300~900
# - 僅示範教育用途;實務需資料校準、監管合規與公平性檢核
def score_applicant(a: dict):
pts = 600
reasons = []
income = a.get("income_twd", 0) # 月收入
dti = a.get("dti", 0.0) # 負債比 (0~1)
late = a.get("late_12m", 0) # 遲繳次數
util = a.get("util", 0.0) # 動用率 (0~1)
age = a.get("age", 0)
hist = a.get("history_years", 0.0)
inq = a.get("inq_6m", 0)
buf = a.get("buffer_months", 0.0)
# 1) 收入(越高越好)
if income < 30000: pts -= 40; reasons.append("收入偏低")
elif income < 60000: pts += 0
elif income < 100000: pts += 20
else: pts += 35
# 2) DTI(越低越好)
if dti > 0.50: pts -= 60; reasons.append("負債比過高")
elif dti > 0.35: pts -= 35; reasons.append("負債比偏高")
elif dti > 0.20: pts -= 15
else: pts += 10
# 3) 繳款紀錄(遲繳越多越差)
if late >= 3: pts -= 60; reasons.append("近一年遲繳≥3")
elif late == 2: pts -= 45; reasons.append("近一年遲繳=2")
elif late == 1: pts -= 30; reasons.append("近一年遲繳=1")
else: pts += 30
# 4) 信用卡動用率(越低越好)
if util > 0.80: pts -= 40; reasons.append("動用率>80%")
elif util > 0.50: pts -= 20; reasons.append("動用率50~80%")
elif util > 0.30: pts -= 10
else: pts += 10
# 5) 年齡(僅示意:極端年齡略減分)
if age < 20: pts -= 20; reasons.append("年齡過低")
elif age < 25: pts -= 10
elif age > 60: pts -= 5
# 6) 信用歷史長度(越長越穩定)
if hist < 1: pts -= 25; reasons.append("信用歷史<1年")
elif hist < 3: pts -= 15
elif hist <= 7: pts += 0
else: pts += 10
# 7) 近 6 月查詢次數(過多代表急需資金)
if inq >= 6: pts -= 25; reasons.append("近6月查詢過多")
elif inq >= 3: pts -= 10
elif inq >= 1: pts -= 5
else: pts += 5
# 8) 現金緩衝(越多越安全)
if buf <= 0: pts -= 20; reasons.append("無現金緩衝")
elif buf < 3: pts -= 10
elif buf <= 6: pts += 0
else: pts += 10
# 分數裁剪與等級
pts = max(300, min(900, pts))
if pts >= 750: grade = "A"
elif pts >= 700: grade = "B+"
elif pts >= 650: grade = "B"
elif pts >= 600: grade = "C"
else: grade = "D"
return {"score": pts, "grade": grade, "reasons": reasons}
# --- 測試三位申請人 ---
applicants = [
{
"name": "Alice",
"income_twd": 85000, "dti": 0.28, "late_12m": 0, "util": 0.35,
"age": 29, "history_years": 4, "inq_6m": 1, "buffer_months": 4
},
{
"name": "Bob",
"income_twd": 42000, "dti": 0.55, "late_12m": 2, "util": 0.82,
"age": 24, "history_years": 1, "inq_6m": 3, "buffer_months": 1
},
{
"name": "Carol",
"income_twd": 120000, "dti": 0.18, "late_12m": 0, "util": 0.20,
"age": 38, "history_years": 9, "inq_6m": 0, "buffer_months": 8
}
]
for a in applicants:
r = score_applicant(a)
print(f"{a['name']:>5} | 分數:{r['score']} | 等級:{r['grade']} | 原因:{', '.join(r['reasons']) or '無'}")
預期輸出(示意)
- Alice:分數約 7xx,等級 B 或 B+,主要因為「無遲繳、DTI 合理」。
- Bob:分數偏低,等級 C 或 D,原因包含「負債比過高、近一年遲繳、動用率高」。
- Carol:分數最高,等級 A,因為收入高、DTI 低、歷史長且無遲繳。
怎麼延伸與調整?
- 調權重:把你覺得最重要的項目(例如遲繳)放更大扣分。
- 加入門檻:如 score < 620 需人工覆核。
- 產出報表:把結果寫入 CSV,做團隊演示或面試作品集。
- 公平性提醒:別引入敏感屬性;測試不同族群/年齡分佈的結果是否明顯偏斜。
- 合規:實務上需符合在地法規(例如可解釋性、資料同意、隱私保護)。